#include "spinlock.h"

void SpinlockLock(SPINLOCK *lock) {
  while (__atomic_test_and_set(lock, 1))
    ;
}

void SpinlockUnlock(SPINLOCK *lock) { *lock = 0; }

BOOLEAN SpinlockTrylock(SPINLOCK *lock) { return !__atomic_test_and_set(lock, 1); }
